package com.coderman.basketball.statistics.service;

import com.coderman.basketball.statistics.context.GameDataBO;
import com.coderman.basketball.statistics.context.GamePlayerDataBO;
import com.coderman.basketball.statistics.dto.GameEventDTO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Description:
 * date: 2021/5/13
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 * 基于比赛活动维度的缓存
 */
@Service
public class CacheService {
    /**
     * 球队数据
     */
    private ConcurrentHashMap<Long, GameDataBO> gameDataBOMap = new ConcurrentHashMap<>();

    /**
     * 比赛事件
     */
    private ConcurrentHashMap<Long, List<GameEventDTO>> gameEventListMap = new ConcurrentHashMap<>();

    /**
     * key:球员ID
     * value:球员当前比赛活动数据
     */
    private ConcurrentHashMap<Long, GamePlayerDataBO> gamePlayerDataBOMap = new ConcurrentHashMap<>();

    /**
     * 初始化当天比赛的基本数据
     */
    public void init(List<Long> gameIdList,List<Long> playerIdList){

    }

    /**
     * 销毁当前比赛数据
     */
    public void clear(Long gameId){
        gameDataBOMap.remove(gameId);
        gameEventListMap.remove(gameId);
    }


    public GameDataBO getGameData(Long gameId){
        return gameDataBOMap.get(gameId);
    }

    public GamePlayerDataBO getGamePlayerDataBO(Long playerId){
        return gamePlayerDataBOMap.get(playerId);
    }

}
